package org.honeyweb.gsoc.services;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import org.honeyweb.gsoc.model.Organizations;
import org.honeyweb.gsoc.model.Users;

@Transactional (readOnly=true, propagation=Propagation.REQUIRED)
public interface UsersManager {
	/**
     * Check if the login exists and if the password is correct. 
     * @param login : user login
     * @param password : user password
     * @return true if the login exists and if the password is correct. 
     * Otherwise, return false. 
     */
    public boolean checkLogin (String login, String password);

    /**
     * Return a User object from a given login.
     * @param login : user login
     * @return the corresponding user object.
     */
    public Users getUser(String login);
    
    /**
     * add a User object in database.
     * @param login : user login
     * @param password : user password
     * @param retypePassword : user retypePassword
     * @param firstName : user firstName
     * @param lastName : user lastName
     * @param mail : user mail
     */
    @Transactional (readOnly=false)
    public void addUser(String login, String password, String retypePassword, String firstName, String lastName, String mail);
    
    /**
     * Change the password to 'password' for the given login
     * @param login : user login
     * @param password : user new password
     * @return the new User object
     */
    
    @Transactional (readOnly=false)
    public Users changePassword (String login, String password);
    
    /**
     * Return the admin of an organization
     * @param organization
     * @return the new User object
     */
    
    public Users getAdmin (Organizations organization);
    
    /**
     * Update the organizationsId of a given user
     * @param organizationsId : int
     * @param id : int (id of the user to update)
     * @return the new User object
     */
    
    @Transactional (readOnly=false)
    public void updateUserOrganizationsId (int organizationsId, int id);
    
    /**
     * Update user information
     * @return void
     */
    
    @Transactional (readOnly=false)
    public void updateUser (String login, String firstName, String lastName, String mail,int id);
    

}
